@extends('admin.admin')


@section('style')
    <link href="{{ asset('dist/lib/fileinput/css/fileinput.min.css') }}" rel="stylesheet">
@endsection
@section('content')
    <div class="main animsition">
        <div class="container-fluid">
            <div class="row">
                <div class="">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">添加轮播图</h3>
                        </div>
                        <div class="panel-body">

                            <form class="form-horizontal" role="form" method="POST" action="{{ url('admin/grid/add_post') }}">
                                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                @include('admin.grid._form')
                                <div class="form-group">
                                    <div class="col-md-7 col-md-offset-3">
                                        <button type="submit" class="btn btn-primary btn-md">
                                            <i class="fa fa-plus-circle"></i>
                                            添加
                                        </button>
                                    </div>
                                </div>

                            </form>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@stop

@section('script')
    <script type="text/javascript" src="{{ asset('dist/lib/fileinput/js/fileinput.min.js') }}"></script>
    <script type="text/javascript" src="{{ asset('dist/lib/fileinput/js/fileinput_locale_zh.js') }}"></script>

    <script type="text/javascript">

        $("#input-24").fileinput({
            // initialPreview: [
            //     "<img src='/images/moon.jpg' class='file-preview-image' alt='The Moon' title='The Moon'>",
            //     "<img src='/images/earth.jpg' class='file-preview-image' alt='The Earth' title='The Earth'>",
            // ],
            showCaption: false,
            showRemove: true,
            showCancel: true,
            uploadAsync:true,
            dropZoneEnabled:true,
            overwriteInitial: false,
            resizeImage: true,
            maxFileSize: 5070,
            initialCaption: "The Moon and the Earth",
            previewFileType :"image",
            uploadUrl: "{{ url('admin/upload_img') }}",
            previewFileIcon:"",
            maxFileCount: 1,
            minFileCount: 1,
            msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}！",
            dropZoneTitle: "把文件拖拽"
        }).on('filedeleted', function(outData) {
            $('input[name=img]').val('');
        }).on("fileuploaded", function(event, outData) {
            //文件上传成功后返回的数据， 此处我只保存返回文件的id
            var result = outData.response.url;
            // 对应的input 赋值
            $('input[name=img]').val(result).change();
        });



    </script>

@endsection